package icu.qx.wm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import icu.qx.wm.domain.GbsGood;
import icu.qx.wm.service.IGbsGoodService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 产品库存Controller
 *
 * @author alize
 * &#064;date  2024-06-14
 */
@RestController
@RequestMapping("/wm/info/product")
public class GbsGoodController extends BaseController {
    private final IGbsGoodService gbsGoodService;

    @Autowired
    public GbsGoodController(IGbsGoodService gbsGoodService) {
        this.gbsGoodService = gbsGoodService;
    }

    /**
     * 查询产品库存列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GbsGood gbsGood) {
        startPage();
        List<GbsGood> list = gbsGoodService.selectGbsGoodList(gbsGood);
        return getDataTable(list);
    }

    /**
     * 导出产品库存列表
     */
    @RequiresPermissions("wm:info:product:export")
    @Log(title = "产品库存", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GbsGood gbsGood) {
        List<GbsGood> list = gbsGoodService.selectGbsGoodList(gbsGood);
        ExcelUtil<GbsGood> util = new ExcelUtil<>(GbsGood.class);
        util.exportExcel(response, list, "产品库存数据");
    }

    /**
     * 查询产品编码
     */
    @RequiresPermissions("wm:info:product:query")
    @GetMapping("/list/code/{isMaterial}")
    public AjaxResult getPdCode(@PathVariable(name = "isMaterial") String isMaterial) {
        return success(gbsGoodService.selectGbsGoodCode(isMaterial));
    }
}
